@extends('Account::layout')

@section('page-main')

    <div class="bg-light p-3 d-flex flex-row-reverse justify-content-between">


        <div class="card flex-shrink-0" style="width: 400px">

            <div class="card-body">
                @section('auth-body')
                @show
            </div>

        </div>
        <div class="card border-0 bg-transparent mr-3 flex-grow-1">
            <div class="card-body">


                <h5 class="card-title border-bottom text-dark pb-3 ">
                    @auth
                        <div class="alert alert-success">
                            <i class="el-icon-circle-check text-success"></i>
                            成功登录用户: <strong>{{authService()::AuthenticatedUser('name')}}</strong>,
                            @if($oauth_data??null)
                                您正在登录【
                                {{data_get($oauth_data,'app.name','')}} {{data_get($oauth_data,'back_name','')}}
                                】，用当前账号 <a class=" btn-link"
                                           href="{{route('web.oauth.redirect-back',['id'=>data_get($oauth_data,'app.id',''),'back_url'=>data_get($oauth_data,'back_url',''),'state'=>data_get($oauth_data,'state','')])}}">请点这里</a>
                            @endif
                            ，若需登录其它账号请在右则操作

                        </div>
                    @else
                        <div class="alert alert-info">
                            @if($oauth_data??null)
                                您正在登录【
                                {{data_get($oauth_data,'app.name','')}} {{data_get($oauth_data,'back_name','')}}
                                】
                            @else
                                欢迎登录【 {{ config('app.name', '') }}】，众多系统均使用本站统一登录管理
                            @endif
                        </div>
                    @endauth
                </h5>
                @if($oauth_data??null)
                    <div class="media">
                        <img src="{{data_get($oauth_data,'app.logo_file_thumb','')}}"
                             class=" img-thumbnail mr-3" alt="" style="max-width: 240px">
                        <div class="media-body">
                            <h5><strong>
                                    <a href="{{data_get($oauth_data,'app.domain','')}}" target="_blank">
                                    {{data_get($oauth_data,'app.name','')}}
                                    </a>
                                </strong></h5>
                            <p  class="text-truncate ellipsis-line-multi ellipsis-line-6">{{data_get($oauth_data,'app.summary','')}}</p>
                            @if(count(data_get($oauth_data,'return_url_others',[])) > 0)
                                <p class="mb-0"><strong>此网站其它应用:</strong>
                                    @foreach(data_get($oauth_data,'return_url_others',[]) as $link)
                                        @auth
                                            @if(data_get($link,'url',''))
                                                <a class="mr-3"
                                                   href="{{route('web.oauth.redirect-back',['id'=>data_get($oauth_data,'app.id',''),'back_url'=>data_get($link,'url','#'),'state'=>data_get($oauth_data,'state','')])}}">{{data_get($link,'name',data_get($link,'url',''))}}</a>
                                            @endif
                                        @else
                                            <span class="mr-3">{{data_get($link,'name',data_get($link,'url',''))}}</span>
                                        @endauth

                                    @endforeach
                                </p>
                            @endif

                        </div>
                    </div>
                @elseif($oauth_apps->isNotEmpty())
                    @foreach($oauth_apps as $oauth_app)
                        <div class="media mb-3 pb-3  border-bottom">
                            <img src="{{data_get($oauth_app,'logo_file_thumb','')}}"
                                 class=" img-thumbnail mr-3" alt="" style="max-width: 120px">
                            <div class="media-body">
                                <h5><strong>
                                        <a href="{{data_get($oauth_app,'domain','')}}" target="_blank">
                                        {{data_get($oauth_app,'name','')}}
                                        </a>
                                    </strong></h5>
                                <p class="text-truncate ellipsis-line-multi ellipsis-line-2 mb-1">{{data_get($oauth_app,'summary','')}}</p>
                                @if(count(data_get($oauth_app,'return_url',[])) > 0)
                                    <p class="mb-0"><strong>应用:</strong>
                                        @foreach(data_get($oauth_app,'return_url',[]) as $link)
                                            @auth
                                                @if(data_get($link,'url',''))
                                                    <a class="mr-3"
                                                       href="{{route('web.oauth.redirect-back',['id'=>data_get($oauth_app,'id',''),'back_url'=>data_get($link,'url','#'),'state'=>data_get($oauth_data,'state','')])}}">{{data_get($link,'name',data_get($link,'url',''))}}</a>
                                                @endif
                                            @else
                                                <span class="mr-3">{{data_get($link,'name',data_get($link,'url',''))}}</span>
                                            @endauth

                                        @endforeach
                                    </p>
                                @endif

                            </div>
                        </div>
                    @endforeach
                @endif


            </div>
        </div>
    </div>

@endsection



